package net.aiion.weave.impl.startup;

import net.aiion.weave.spi.naming.ConversationContext;
import net.aiion.weave.spi.naming.callbacks.FeedDispatchedCallback;
import net.aiion.weave.spi.naming.callbacks.RouteDispatchedCallback;
import net.aiion.weave.spi.startup.ConversationContextStartup;

public class ConversationContextStartupImpl implements ConversationContextStartup
{
    private final ConversationContext conversationContext;

    public ConversationContextStartupImpl(final ConversationContext aConversationContext) {
        conversationContext = aConversationContext;
    }

    @Override
    public String getConversationContextId() {
        return conversationContext.getId();
    }

    @Override
    public ConversationContextStartup dispatchRoute(final String aRoute) {
        return dispatchRoute(aRoute, null);
    }

    @Override
    public ConversationContextStartup dispatchRoute(final String aRoute,
        final RouteDispatchedCallback aRouteDispatchedCallback)
    {
        conversationContext.dispatchRoute(aRoute, aRouteDispatchedCallback);
        return this;
    }

    @Override
    public ConversationContextStartup dispatchFeed(final String aFeedName, final String aFeedValue) {
        return dispatchFeed(aFeedName, aFeedValue, null);
    }

    @Override
    public ConversationContextStartup dispatchFeed(final String aFeedName, final String aFeedValue,
        final FeedDispatchedCallback aFeedDispatchedCallback)
    {
        conversationContext.dispatchFeed(aFeedName, aFeedValue, aFeedDispatchedCallback);
        return this;
    }

    @Override
    public void executeShutdown() {
        conversationContext.dispose();
    }
}
